<template>
  <div>
    <!-- 顶部导航 -->
    <van-nav-bar
      title="我的信息"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
    >
    </van-nav-bar>
    <!-- 地址 -->
    <van-address-edit
      :area-list="areaList"
      show-postal
      show-delete
      show-set-default
      show-search-result
      :search-result="searchResult"
      :area-columns-placeholder="['请选择', '请选择', '请选择']"
      @save="onSave"
      @delete="onDelete"
      @change-detail="onChangeDetail"
    />
    <!-- 底部选项卡 -->
    <van-tabbar v-model="active" fixed>
      <van-tabbar-item icon="wap-home-o" to="/">主页</van-tabbar-item>
      <van-tabbar-item
        icon="shopping-cart-o"
        to="/shopcart"
        :badge="`${this.sname}`"
      >
        购物车
      </van-tabbar-item>
      <van-tabbar-item icon="user-o">我的</van-tabbar-item>
    </van-tabbar>
  </div>
</template>
<style lang="">
</style>
<script>
import { mapState } from "vuex";
import Vue from "vue";
import { Toast } from "vant";
Vue.use(Toast);
export default {
  data() {
    return {
      //底部导航
      active: 2,
      //地址
      areaList:{},
      searchResult: [],
    };
  },
  computed: {
    ...mapState(["sname"]),
  },
  methods: {
    onSave() {
      Toast("save");
    },
    onDelete() {
      Toast("delete");
    },
    onChangeDetail(val) {
      if (val) {
        this.searchResult = [
          {
            name: "黄龙万科中心",
            address: "杭州市西湖区",
          },
        ];
      } else {
        this.searchResult = [];
      }
    },
    onClickLeft() {
      this.$router.go(-1);
    },
  },
};
</script>